package com.atguigu.spzx.manager.controller;

import com.atguigu.spzx.manager.service.SysUserService;
import com.atguigu.spzx.manager.service.SysUserServiceZxw;
import com.atguigu.spzx.model.dto.system.AssginRoleDto;
import com.atguigu.spzx.model.dto.system.SysUserDto;
import com.atguigu.spzx.model.entity.system.SysUser;
import com.atguigu.spzx.model.vo.common.Result;
import com.atguigu.spzx.model.vo.common.ResultCodeEnum;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping(value = "/zxw/admin/system/sysUser")
public class SysUserControllerZxw {

    @Autowired
    private SysUserServiceZxw sysUserServiceZxw;

    //1 用户条件分页查询接口---这个方法好像没有成功
    @GetMapping(value = "/findByPage/{pageNum}/{pageSize}")
    public Result findByPage(@PathVariable("pageNum") Integer pageNum,
                             @PathVariable("pageSize") Integer pageSize,
                             @RequestBody SysUserDto sysUserDto) {
        PageInfo<SysUser> pageInfo = sysUserServiceZxw.findSysUserByPage(pageNum,pageSize,sysUserDto);
        System.out.print("\33[44;1m"+pageInfo+"\n\33[0m");
        return Result.build(pageInfo, ResultCodeEnum.SUCCESS);
    }

    @PostMapping(value = "/saveSysUser")
    public Result saveSysUser(@RequestBody SysUser sysUser) {
        sysUserServiceZxw.saveSysUser(sysUser) ;
        System.out.print("\33[44;1m"+"保存的sysUser的信息是："+sysUser+"\n\33[0m");
        return Result.build(sysUser , ResultCodeEnum.SUCCESS) ;
    }


}
